<?php

namespace App\Admin\Controllers;

use App\Admin\Forms\Sheet1;
use App\Admin\Forms\Sheet10;
use App\Admin\Forms\Sheet2;
use App\Admin\Forms\Sheet3;
use App\Admin\Forms\Sheet4;
use App\Admin\Forms\Sheet5;
use App\Admin\Forms\Sheet6;
use App\Admin\Forms\Sheet7;
use App\Admin\Forms\Sheet8;
use App\Admin\Forms\Sheet9;
use App\Admin\Forms\WechatBdReply;
use App\Admin\Forms\WechatMenu;
use App\Admin\Forms\WechatZdReply;
use App\Http\Controllers\Controller;
use App\Models\ExcelRule;
use Encore\Admin\Layout\Content;
use Encore\Admin\Widgets\Tab;

class ExcelSettingController extends Controller
{
    public function index(Content $content)
    {
        $templateId = request()->input('template_id');
        $list = ExcelRule::query()->where('template_id', $templateId)->select([
            'id', 'title', 'type', 'template_id',
        ])->where('is_del', 0)->get();
        $sheetList = $list->pluck('type');

        $map = [
            'sheet1'  => Sheet1::class,
            'sheet2'  => Sheet2::class,
            'sheet3'  => Sheet3::class,
            'sheet4'  => Sheet4::class,
            'sheet5'  => Sheet5::class,
            'sheet6'  => Sheet6::class,
            'sheet7'  => Sheet7::class,
            'sheet8'  => Sheet8::class,
            'sheet9'  => Sheet9::class,
            'sheet10' => Sheet10::class,
        ];
        $forms = [];
        foreach ($sheetList as $item) {
            if (isset($map[$item])) {
                $forms[$item] = $map[$item];
            }
        }
        return $content
            ->title('表单导出配置')
            ->body(Tab::forms($forms));
    }
}
